home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / doslbs.zip / DOSLIB09.CLA < prev   
Text File  |  1994-02-12  |  7KB  |  149 lines

  1.                 MEMBER('DOSLIB')
  2. OMIT('╝')
  3. ╔════════════════════════════════════════════════════════════════════════════╗
  4. ║ Printer_Select -                               !Generated Procedure        ║
  5. ╚════════════════════════════════════════════════════════════════════════════╝
  6.  
  7. Select_Printer   Function(Dsp:PrinterName,Control:File)
  8.  
  9.                  Map
  10.                    Module('C Standard Library')
  11.                      DL:Access(*Cstring,Short),Short,Raw,Name('_access')
  12.                  . .
  13.  
  14. New:PrinterFile  CString(64),STATIC
  15. New:PrinterName  String(64)
  16.  
  17. CtlFile          FILE,DRIVER('ASCII'),NAME(New:PrinterFile),PRE(Dos)
  18. RECORD           RECORD
  19. Line               STRING(255)
  20.                  . .
  21. Queue            QUEUE,PRE(Que)
  22. QueueLine          STRING(80)
  23.                  .
  24.  
  25. LoadingScreen    SCREEN(4,32),CENTER,SHADOW,CUA,COLOR(1)
  26.                    !dimensions=25,80,25,80
  27.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  28.                    ROW(3,5)    PAINT(1,25),COLOR(8)
  29.                    ROW(1,1)    STRING('█{8}'),COLOR(3)
  30.                      COL(9)    STRING('Loading Printers'),COLOR(2)
  31.                      COL(25)   STRING('█{8}'),COLOR(3)
  32.                    ROW(4,1)    STRING('█▄{30}█'),COLOR(3)
  33.                                REPEAT(2)
  34.                    ROW(2,1)      STRING('█'),COLOR(3)
  35.                    ROW(2,32)     STRING('█'),COLOR(3)
  36.                                .
  37.                                REPEAT(1,25),INDEX(ShowIndx#)
  38. ShowPercentage     ROW(3,4)      STRING(@s1),COLOR(8)
  39.                                .
  40.                  .
  41. SCREEN           SCREEN(22,41),PRE(SCR),CENTER,SHADOW,FADE,CUA,COLOR(1)
  42.                    !dimensions=25,80,25,80
  43.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  44.                    ROW(1,1)    STRING('█{9}'),COLOR(113)
  45.                      COL(10)   STRING('Printer Selection Table'),COLOR(2)
  46.                      COL(33)   STRING('█{9}'),COLOR(113)
  47.                    ROW(22,1)   STRING('█▄{39}█'),COLOR(113)
  48.                                REPEAT(20)
  49.                    ROW(2,1)      STRING('█'),COLOR(113)
  50.                    ROW(2,41)     STRING('█'),COLOR(113)
  51.                                .
  52.                    ROW(3,4)    PROMPT('Current Printer :'),COLOR(4,5,40,6,7)
  53.                    ROW(4,4)    ENTRY(@s35),USE(New:PrinterName),OVR,SKIP,COLOR(8,9,38)
  54.                    ROW(6,4)    LIST(13,35),FROM(Que:QueueLine),HVSCROLL,USE(?Queue),IMM,COLOR(21,22,68)
  55.                    ROW(20,5)   BUTTON(' &Select '),SHADOW,KEY(EnterKey),USE(?Ok),COLOR(17,18,39,19,20)
  56.                      COL(17)   BUTTON('  &Edit  '),SHADOW,USE(?Edit),COLOR(17,18,39,19,20)
  57.                      COL(29)   BUTTON(' &Cancel '),SHADOW,USE(?Cancel),COLOR(17,18,39,19,20)
  58.                  .
  59.  
  60.                  CODE
  61.                  If ~Omitted(2) then
  62.                     New:PrinterFile = Control:File
  63.                  Else
  64.                     New:PrinterFile = Command('CLAPRINTER',0)
  65.                  .
  66.                  If Clip(New:PrinterFile) = '' then New:PrinterFile = 'PRINTER.CTL'.
  67.  
  68.  
  69.                  OPEN(Screen)                         !Open the screen
  70.                  DO FillQueue
  71.                  DISPLAY
  72.                  LOOP                                 !Loop through the fields
  73.                    CASE SELECTED()                    !Jump to field setup routine
  74.                    END                                !End CASE
  75.                    ACCEPT                             !Enable the mouse and keyboard
  76.                    CASE FIELD()                       !Jump to field edit routine
  77.                    OF ?Queue                          !If List box field
  78.                       GET(Queue,CHOICE())             ! Get the selected printer name
  79.                    Of ?Edit
  80.                       ViewPrinters(New:PrinterFile)
  81.                       Do FillQueue
  82.                    OF ?Ok                             !If selecting a printer
  83.                       New:PrinterName = Que:QueueLine ! Save the printer name
  84.                       BREAK                           ! Break to exit
  85.                    OF ?Cancel                         !If no printer name change
  86.                       BREAK                           ! Break to exit
  87.                  . .                                  !End CASE
  88.                  CLOSE(CtlFile)                       !Close the control file
  89.                  FREE(Queue)                          !Free the QUEUE memory
  90.                  Return(New:PrinterName)
  91.  
  92. FillQueue        ROUTINE
  93.  
  94.                  Open(CtlFile)
  95.                  If Error() then
  96.                     Beep
  97.                     New:PrinterFile = GetFileDetails('PRINTER.CTL','Printer Control File','*.CTL')
  98.                     If Clip(New:PrinterFile) = '' then Return('').
  99.                     Open(CtlFile)
  100.                     If Error() then Return('').
  101.                  .
  102.  
  103.                  If ~Omitted(1) then
  104.                     New:PrinterName = Dsp:PrinterName
  105.                  .
  106.  
  107.                  Open(LoadingScreen)
  108.                  Loop ShowIndx# = 1 to 25
  109.                       ShowPercentage = ' '
  110.                  .
  111.                  TotalBytes#       = Bytes(CtlFile)
  112.                  TotalCntr#        = 0
  113.                  TotalRead#        = 0
  114.                  LastCntr#         = 1
  115.  
  116.                  Free(Queue)
  117.                  SET(CtlFile)                              !Set to loop in file order
  118.                  LOOP                                      !While records found
  119.                    NEXT(CtlFile)                           ! Get the next record
  120.                    IF ERRORCODE() THEN BREAK.                ! Break if no more records
  121.  
  122.                    TotalRead#     += Bytes(CtlFile)
  123.                    TotalCntr#      = ((TotalRead# * 100) / TotalBytes#) / 4
  124.                    If TotalCntr# > LastCntr# then
  125.                       Loop ShowIndx# = LastCntr# to TotalCntr#
  126.                         ShowPercentage = '▒'
  127.                       .
  128.                       LastCntr# = TotalCntr#
  129.                    .
  130.  
  131.                    IF CLIP(UPPER(Dos:Line)) = 'PRINTERS'   ! If on the 'PRINTERS' line
  132.                       CYCLE                                ! Ignore it
  133.                    .                                       ! End IF
  134.                    IF CLIP(UPPER(Dos:Line)) = 'PORTS'      ! If on the 'PORTS' line
  135.                       BREAK                                ! Quit reading from file
  136.                    .                                       ! End IF
  137.                    IF CLIP(UPPER(Dos:Line)) = 'CONTROLS'   ! If on the 'CONTROLS' line
  138.                       BREAK                                ! Quit reading from file
  139.                    .                                       ! End IF
  140.                    SpacePosition# = INSTRING(' ',Dos:Line,1,1)! Find the first space
  141.                    Que:QueueLine = SUB(Dos:Line,SpacePosition#+1,LEN(CLIP(Dos:Line))-SpacePosition#)
  142.                    ADD(Queue)                              ! Add the name to the QUEUE
  143.                  .                                         !End LOOP
  144.                  Close(LoadingScreen)
  145.                  Close(CtlFile)
  146.                  Select(?Queue,1)
  147.                  Exit
  148.  
  149.